import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime' // 到指定时间需要的插件
import zh from 'dayjs/locale/zh' // 集成中文

export const formatTime = (str) => {
  dayjs.extend(relativeTime)
  dayjs.locale(zh)
  return dayjs(str).fromNow()
}

export const formatDate = (dateObj) => {
  return dayjs(dateObj).format('YYYY-MM-DD')
}
